﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Pharmacy;

namespace Adminka
{
    public partial class Form1 : Form
    {
        SQLaccessAdmin sql = null;
        public Form1()
        {
            InitializeComponent();

            panel1.Visible = false;
            panel1.BackColor = Color.Green;
            panel2.Visible = false;
            panel2.BackColor = Color.Green;
            panel3.Visible = false;
            panel3.BackColor = Color.Red;

            sql = new SQLaccessAdmin(@"../../../BaZa_Apteka.mdb");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            panel2.Visible = false;
            panel3.Visible = false;
            panel1.Visible = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            panel1.Visible = false;
            panel3.Visible = false;
            panel2.Visible = true;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            panel1.Visible = false;
            panel2.Visible = false;
            panel3.Visible = true;
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (sql.Registration(textBox1.Text, textBox2.Text, textBox4.Text, textBox3.Text, textBox5.Text))
            {
                label6.Visible = true;
                label6.BackColor = Color.Green;
                label6.Text = "Успешно добавлен новий работник!";
            }
            else
            {
                label6.Visible = true;
                label6.BackColor = Color.Red;
                label6.Text = "Проверьти дание водимие о работнеке!";
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            //AddMedicine
            int id = sql.AddMedicine(textBox6.Text);
            double kol = 0;
            double prs = 0;
            Double.TryParse(textBox11.Text, out kol);
            Double.TryParse(textBox7.Text, out prs);
            //AddNamber
            sql.AddNamber(id, (int)kol, (int)prs, DateTime.Now.ToString());
            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                //AddSymptoms
                sql.AddSymptoms(id, listBox1.Items[i].ToString());
            }
            for (int i = 0; i < listBox2.Items.Count; i++)
            {
                //AddActiveMaterial
                sql.AddActiveMaterial(id, listBox2.Items[i].ToString());
            }
            sql.AddForm(id, comboBox1.Text);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            int id = 0;
            double kol = 0;
            double prs = 0;
            Double.TryParse(textBox9.Text, out kol);
            Double.TryParse(textBox12.Text, out prs);
            sql.AddNamber(id, (int)kol, (int)prs, dateTimePicker1.Value.Day.ToString() + ":" + dateTimePicker1.Value.Month.ToString() + ":" + dateTimePicker1.Value.Year.ToString());
        }

        private void button7_Click(object sender, EventArgs e)
        {
            listBox1.Items.Add(textBox8.Text);
            textBox8.Text = "";
        }

        private void button8_Click(object sender, EventArgs e)
        {
            listBox2.Items.Add(textBox10.Text);
            textBox10.Text = "";
        }
    }
}
